#pragma once

#include <iostream>
#include <string>

class Task
{
public:
    enum Task_Error
    {
        Task_Operator_Error = -2,
        Task_Operator_Div_Zero = -1,
        Task_Operator_True = 0
    };

    Task(int left = 0, int right = 0, char oper = '\0')
        : _left(left)
        , _right(right)
        , _oper(oper)
        , _result(0)
        , _exit(Task_Operator_True)
    {}

    void run()
    {
        switch (_oper)
        {
        case '+' :
            _result = _left + _right;
            break;
        case '-' :
            _result = _left - _right;
            break;
        case '*' :
            _result = _left * _right;
            break;
        case '/' :
            if (_right)
                _result = _left / _right;
            else
                _exit = Task_Operator_Div_Zero;
            break;
        case '%' :
            if (_right)
                _result = _left % _right;
            else
                _exit = Task_Operator_Div_Zero;
            break;
        default:
                _exit = Task_Operator_Error;
            break;
        }
    }
    void operator()()
    {
        run();
    }

    std::string get_result()
    {
        std::string ret = std::to_string(_left);
        ret += _oper;
        ret += std::to_string(_right);
        ret += "=";
        ret += std::to_string(_result);
        ret += " exit:";
        ret += std::to_string(_exit);
        return ret;
    }
    std::string get_task()
    {
        std::string ret = std::to_string(_left);
        ret += _oper;
        ret += std::to_string(_right);
        ret += "=?";
        return ret;
    }
private:
    int _left = 0;
    int _right = 0;
    char _oper = '\0';

    int _result = 0;
    int _exit = 0;
};